package com.TetrisII.views;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Toolkit;
import java.net.URL;

import javax.swing.JPanel;

import com.TetrisII.entities.Ground;

/**
 * 分数面板
 * 
 * @author Administrator
 *
 */
public class GoalsPanel extends JPanel {
	private Ground ground;

	public GoalsPanel(Ground ground) {
		this.ground = ground;
		setBackground(Color.PINK);
		setPreferredSize(new Dimension(200, 200));
		setVisible(true);

	}

	/**
	 * 画出得分
	 */
	@Override
	public void paint(Graphics g) {
		// TODO Auto-generated method stub
		super.paint(g);
		Graphics2D g_2 = (Graphics2D) g;
		URL url=GoalsPanel.class.getResource("显示分数背景.PNG");
		Image image=Toolkit.getDefaultToolkit().getImage(url);
		g_2.drawImage(image,0, 0, 200,200, this);
		g_2.setColor(Color.WHITE);
		g_2.setFont(new Font("Serif", Font.BOLD, 15));
		g.drawString("您现在的分数是:" + ground.getGoals(), 10, 80);
		repaint();
	}

}
